/*
 * CpuMemory.java
 *
 * Created on 5 de Dezembro de 2007, 00:06
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.google.code.jbrnes.core;

/**
 *
 * @author Leandro
 *
 */
public class CpuMemory {
    
    /** Creates a new instance of CpuMemory */
    public CpuMemory() {
    }
    
    //component memory
    // 4B * 65535 = 256K
    // the original memory uses just 32K.
    private int[] memory = new int[0x10000];
    
    public int readFrom(int adress){
        return memory[adress];
    }
    
    public void writeAt(int adress,int data){
        if ((adress >= CpuMemoryMap.CARTRIDGE_PRG_ROM_START) || (adress <= CpuMemoryMap.CARTRIDGE_PRG_ROM_END)){
            throw new IllegalArgumentException("Trying to write on ROM area! [$" + adress + "]");
        }                
        
        
        
        memory[adress] = data;
    }
    
    
}
